package exotica.rs2.net.codec;

import java.util.logging.Logger;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.frame.FrameDecoder;

/**
 * @author Sir Tom
 *
 */
public class ServerLoginDecoder extends FrameDecoder {

	private static final int GAME_OPCODE = 14;
	private static final int CONNECT = 16;
	private static final int RECONNECT = 18;
	
    @Override
	protected Object decode(ChannelHandlerContext ctx, Channel ch, ChannelBuffer cb) throws Exception {
		final int opcode = cb.readByte() & 0xFF;
		switch(opcode) {
		case GAME_OPCODE:
			sendGameOpcode(ctx, ch, cb);
			break;
		case CONNECT:
			sendConnect(ctx, ch, cb);
			break;
		case RECONNECT:
			sendReconnect(ctx, ch, cb);
			break;
			default:
				Logger.getAnonymousLogger().info("Unhandled Opcode: ["+opcode+"]");
		}
		return null;
	}

	private void sendGameOpcode(ChannelHandlerContext ctx, Channel ch, ChannelBuffer cb) {
		
    }

	private void sendReconnect(ChannelHandlerContext ctx, Channel ch, ChannelBuffer cb) {	
		
	}

	private void sendConnect(ChannelHandlerContext ctx, Channel ch, ChannelBuffer cb) {	
		
	}

}

